<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <div>宽度： <span id="width"></span></div>
    <div>高度： <span id="height"></span></div>
</div>
</body>
</html>
<script>
    window.addEventListener('resize', handleResize)

    function handleResize() {
        console.log(window)
        const width = window.innerWidth;
        const height = window.innerHeight;
        document.getElementById('width').value = width
        document.getElementById('height').value = height
    }
</script>
